﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HotelResSystem2
{
    public partial class RoomList : Form
    {
        public static RoomList Instance()
        {
            if (Rooms == null)
            {
                Rooms = new RoomList();
            }
            return Rooms;
        }
        private static RoomList Rooms = null;

        public string SelectedRoom
        {
            get
            {
                return _SelectedRoom;
            }
        }
        private string _SelectedRoom = "";

        public void SetRoomsData(List<KeyValuePair<int,string>> roomlist)
        {
            if (roomlist.Count > 0)
            {
                RoomsListBox.DataSource = roomlist;
                RoomsListBox.DisplayMember = "Value";
                RoomsListBox.ValueMember = "Key";
            }
            else
            {
                RoomsListBox.Text = "No room at the inn";
            }
        }

        private RoomList()
        {
            InitializeComponent();
        }

        private void OkButton_Click(object sender, EventArgs e)
        {
            if (RoomsListBox.SelectedItem != null)
            {
                _SelectedRoom = RoomsListBox.SelectedValue.ToString();
            }
            this.Close();
        }
    }
}
